/*
 *   AS IS License
 * ==Naive Coders==
 */
package dividematch;

import org.naive.crunch.Fragmenter;
import org.naive.data.NodeType;
import org.naive.data.Tree;

/**
 *
 * @author gbu.000
 */
public class DivideMatch {

    private static Tree generateTree(int kids) {
        final Tree t = new Tree(random(NodeType.values()));
        for (int i = 0; i < (Math.random() * kids); i++) {
            t.add(generateTree((int) (Math.random() * kids)));
        }
        return t;
    }

    private static <T> T random(T[] els) {
        return els[(int) (Math.random() * els.length)];
    }

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        Tree t = generateTree(4);
        Fragmenter f = new Fragmenter(t);
        while (f.next() != null) {
        }
        System.out.println("done");
    }
}
